package com.hyou.springboot2.service.base.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.hyou.springboot.base.BaseService;
import com.hyou.springboot2.dao.SysRoleMenuDao;
import com.hyou.springboot2.service.base.itfc.SysRoleMenuService;
import com.hyou.springboot2.dto.pojo.SysRoleMenuDO;

/**
 * SysRoleMenuServiceImpl Service接口实现类
 *
 * @author FengChangshuo
 * @version 1.0.0 2018-11-01 13:53:25 初始创建
 */
public class SysRoleMenuServiceImpl extends BaseService implements SysRoleMenuService {
    
    @Override
    public void insert(SysRoleMenuDO paramBean) {
        getMapper(SysRoleMenuDao.class).insert(paramBean);
    }
    
    @Override
    public void insertBatch(List<SysRoleMenuDO> paramBeans) {
        getMapper(SysRoleMenuDao.class).insertBatch(paramBeans);
    }
    
    @Override
    public void deleteByRoleId(Long roleId) {
        getMapper(SysRoleMenuDao.class).deleteByRoleId(roleId);
    }
    
    @Override
    public void deleteBatchByRoleIds(String roleIds) {
        String[] idArray = StringUtils.split(roleIds, ',');
        List<Long> idLst = new ArrayList<>();
        for (String item : idArray) {
            idLst.add(Long.valueOf(item));
        }
        
        deleteBatchByRoleIds(idLst);
    }
    
    @Override
    public void deleteBatchByRoleIds(List<Long> roleIds) {
        getMapper(SysRoleMenuDao.class).deleteBatchByRoleIds(roleIds);
    }
    
    @Override
    public List<SysRoleMenuDO> listByConditions(SysRoleMenuDO paramBean) {
        return getMapper(SysRoleMenuDao.class).selectByConditions(paramBean);
    }
    
    @Override
    public PageInfo<SysRoleMenuDO> listByPage(SysRoleMenuDO paramBean, final int pageNum, final int pageSize) {
        PageMethod.startPage(pageNum, pageSize);
        List<SysRoleMenuDO> lst = getMapper(SysRoleMenuDao.class).selectByConditions(paramBean);
        return new PageInfo<>(lst);
    }
    
}
